<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>岗位管理</title>
<script src="${ctx}/static/selectWin/fndPostSelector.js?version=${applicationScope.jsVersion }" type="text/javascript">
	
</script>
<script type="text/javascript">
	var $tree;
	var $grid;
	var selectTableRow;//选中的行数据
	$(function() {

		$grid = $("#grid").datagrid($.extend(datagridOption, {
			url : "${ctx}/fnd/fndPost/dataGrid",
			fitColumns : true,
			columns : [ [ {
				field : 'id',
				checkbox : true
			}, {
				field : 'postNo',
				title : '岗位编码',
				width : 40,
				sortable : true
			}, {
				field : 'postName',
				title : '岗位名称',
				width : 60,
				sortable : true
			}, {
				field : 'description',
				title : '描述',
				width : 60,
				sortable : true
			}, {
				field : 'enable',
				title : '是否启用',
				width : 60,
				sortable : true,
				formatter : function(value, row, index) {
					return value == 1 ? "是" : "否";
				}
			} ] ]
		}));

		$("#add").click(function() {
			$("#dlg").dialog("open").dialog("setTitle", "新增岗位");
			$("#fm").form("clear").form("load", {
				description : '请在这里输入职位描述'
			});
			$("#radio1").attr("checked", "checked");

		});
		$("#edit").click(function() {
			var row = $("#grid").datagrid("getSelected");
			if (row == null) {
				showAlert("您未选择任何记录!");
			} else {
				$("#dlg").dialog("open").dialog("setTitle", "编辑岗位--[" + row.postName + "]");
				$("#fm").form("clear").form("load", row);
			}
		});
		$("#delete").click(function() {
			multiDeleteDataGrid($("#grid"), "${ctx}/fnd/fndPost/multiDelete");
		});
		$("#excelExport").click(
				function() {
					var url = "${ctx}/fnd/fndPost/excelExport?" + $.param($("#grid").datagrid('options').queryParams) + "&orgId="
							+ selectTableRow.id;
					if ($("#grid").datagrid("options").filterRules) {
						url += "&filterRules=" + JSON.stringify($("#grid").datagrid("options").filterRules);
					}
					window.parent.location.href = url;
				});
	});
	function fun_post_save() {
		var i = 0;
		if ($("#postNo").val() == null) {
			$.messager.show({
				msg : "您未输入岗位编号！",
				icon : "warning",
				position : "bottomRight"
			});
			i = 1;
		}
		if ($("#postName").val() == null) {
			$.messager.show({
				msg : "您未输入岗位名称！",
				icon : "warning",
				position : "bottomRight"
			});
			i = 1;
		}
		$("#fm").form("submit", {
			url : "${ctx}/fnd/fndPost/update",
			success : function(data) {
				if (data.success) {
					$("#dlg").dialog("close");
					$grid.datagrid("reload");
				}
				showInfo(data.msg);
			}
		});
	}
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<div id="cc" class="easyui-layout" data-options="fit:true" style="width: 680px; height: 440px;">
			<div id="dlg1" data-options="region:'center',split: true, collapsible:true,title : '岗位信息'" style="padding: 1px; witdh: 600px">
				<div id="tt" class="row">

				<div class="col-md-12">
					<!-- 查询条件 -->
					<input type="text" id="search_EQ_orgId"
						style="margin-left: 2px; margin-right: 2px; padding-left: 2px; padding-right: 3px; display: none;" />
					<!-- 功能按钮 -->
					<shiro:hasPermission name="fndPost:update">
						<button id="add" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-plus"></span> 新增
				</button>
				<button id="edit" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-pencil"></span> 编辑
				</button>
					</shiro:hasPermission>
					<shiro:hasPermission name="fndPost:delete">
						<button id="delete" type="button" class="btn btn-danger">
					<span class="glyphicon glyphicon-minus"></span> 删除
				</button>
					</shiro:hasPermission>
					<shiro:hasPermission name="fndPost:export">
						<button id="excelExport" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-save"></span> Excel导出
				</button>
					</shiro:hasPermission>
				</div>
				</div>
				<table id="grid">
				</table>
				<shiro:hasPermission name="fndPost:update">
					<div id="dlg" class="easyui-dialog" style="width: 600px; height: 400px; padding: 10px 20px" closed="true"
						data-options="iconCls:'icon-save',resizable:true,modal:true, buttons:[
	                    { text: '保存', iconCls: 'icon-ok', handler: function () { fun_post_save(); } },
	                    { text: '取消', iconCls:'icon-cancel', handler: function () { $('#dlg').dialog('close'); } }
	                ],closed:true">
						<form id="fm" method="post">
							<input id="id" type="hidden" name="id" />
							<table id="tbl">
								<tr>
									<td><label>岗位编码:</label></td>
									<td><input id="postNo" name="postNo" class="easyui-validatebox" data-opations="required:true" /></td>
								</tr>
								<tr>
									<td><label>岗位名称:</label></td>
									<td><input id="postName" name="postName" class="easyui-validatebox" data-opations="required:true" /></td>
								</tr>
								<tr>
									<td><label>启用:</label></td>
									<td><input id="radio1" name="enable" type="radio" value="1" /><label for="radio1">是</label> <input id="radio2" name="enable"
										type="radio" value="2" /><label for="radio2">否</label></td>
								</tr>
								<tr>
									<td><label>描述:</label></td>
									<td><textarea name="description" onmouseover="if((this.value=='') ||(this.value=='请在这里输入职位描述'))
											{this.value='';}"
											onmouseout="if(this.value==''){
									this.value = '请在这里输入职位描述';
								}" rows="8" cols="20">请在这里输入职位描述</textarea></td>
								</tr>
							</table>
						</form>
					</div>
				</shiro:hasPermission>
			</div>
		</div>
	</div>
</body>
</html>
